package com.bj58.aop.interceptor;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.bj58.aop.annotation.NotAdult;

public class NoAdultInterceptor implements MethodInterceptor {

	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {

		NotAdult notAdult = invocation.getMethod().getAnnotation(NotAdult.class);

		int age = notAdult.age();
		if(age<18){
			System.out.println("未成年人不能看此书");
			return null;
		}
		return invocation.proceed();
	}

}
